<?php
/**
 * Created by PhpStorm.
 * User: white
 * Date: 2020/3/19
 * Time: 12:30
 */

namespace app\common\validate;

use think\Validate;

class Admin extends Validate
{
     protected $rule = [
         'username|管理员账户' => 'require',
         'code|验证码'=> 'require',
         'password|密码' => 'require',
         'conpass|确认密码' => 'require|confirm:password',
         'nickname|昵称' => 'require',
         'email|邮箱' => 'require|email',

     ];

     //登录验证场景
     public function sceneLogin(){
        return $this -> only(['username','password']);
     }

     //注册场景验证
    public function sceneRegister(){
         return $this -> only(['username','password','conpass','nickname','email'])
             -> append([
                 'username'=>'unique:admin',
                 'nickname'=>'unique:admin',
                 'email'=>'unique:admin'
             ]);
    }

    //重置密码用户名场景验证
    public function sceneForget(){
         return $this -> only(['username']);
    }

    //重置密码验证码场景验证
    public function sceneReset(){
         return $this -> only(['code','password','conpass']);
    }

}